package com.heima.article.controller.v1;

import com.heima.article.service.IApArticleService;
import com.heima.common.constants.UserConstant;
import com.heima.model.acticle.dtos.ArticleHomeDto;
import com.heima.model.acticle.pojos.ApArticle;
import com.heima.model.common.dtos.ResponseResult;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

@RestController
@RequestMapping("/api/v1/article")
public class ApArticleController {

    @Resource
    private IApArticleService apArticleService;


    @PostMapping("/load")
    public ResponseResult<List<ApArticle>> load(@RequestBody ArticleHomeDto dto) {
        return ResponseResult.okResult(apArticleService.load(UserConstant.LOAD_DEFAULT,dto));
    }

    @PostMapping("/loadmore")
    public ResponseResult<List<ApArticle>> loadMore(@RequestBody ArticleHomeDto dto) {
        return ResponseResult.okResult(apArticleService.load(UserConstant.LOAD_MAX,dto));
    }

    @PostMapping("/loadnew")
    public ResponseResult<List<ApArticle>> loadNew(@RequestBody ArticleHomeDto dto) {
        return ResponseResult.okResult(apArticleService.load(UserConstant.LOAD_MIN,dto));
    }

}
